//-----------------------------------------------------------------------
//  This file is part of the Microsoft Code Samples.
// 
//  Copyright (C) Microsoft Corporation.  All rights reserved.
// 
//  This source code is intended only as a supplement to Microsoft
//  Development Tools and/or on-line documentation.  See these other
//  materials for detailed information regarding Microsoft code samples.
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//-----------------------------------------------------------------------

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;

namespace Microsoft.Samples.SqlServer
{
    [WebService(Namespace = "http://schemas.microsoft.com/sqlserver/samples/hrwebservice/2005/03/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Service : System.Web.Services.WebService
    {
        public Service()
        {

        }

        /// <summary>
        ///		Locate candidates who match the specified search criteria.  Return the 
        ///		results in a data table in a data set.
        /// </summary>
        /// <param name="candidateName">What the candidate might be called</param>
        /// <param name="fromSubmitDate">The low end of a date range for when information about the candidate has been changed</param>
        /// <param name="toSubmitDate">The high end of a data range for when the information about the candidate has been changed</param>
        /// <param name="fullText">Words which might be contained in the resume</param>
        /// <param name="andResults">Whether to union (or) or intersection (and) the results</param>
        /// <returns>A DataSet containing the job candidate id, the full name of the candidate, and the last modified date</returns>
        [WebMethod(Description = "Search through existing resumes", EnableSession = false)]
        public DataSet SearchResumes(string candidateName,
                                   DateTime fromModifyDate,
                                   DateTime toModifyDate, string fullText,
                                   bool andResults,
                                   int lcid)
        {
            // Invoke the data access component to fetch the results.
            DataAccess da = new DataAccess();

            return da.SearchResumes(candidateName, fromModifyDate, toModifyDate,
                             fullText, andResults, lcid, User.Identity.Name);
        }

        /// <summary>
        ///		Fetches the XML representation of the specified candidate's resume.
        /// </summary>
        /// <param name="candidateID">Which candidate to examine</param>
        /// <returns>A String containing the XML which represents the candidates resume</returns>
        [WebMethod(Description = "Return the XML representation of the specified candidate's CV",
            EnableSession = false)]
        public string ResumeContents(int candidateID)
        {
            //Invoke the data access component to fetch the results
            DataAccess da = new DataAccess();

            return da.ResumeContents(candidateID, User.Identity.Name);
        }

        /// <summary>
        ///		Returns the set of languages supported by full text search.
        /// </summary>
        /// <returns>An array of LCIDs</returns>
        [WebMethod(Description = "Return an array of LCIDs which represent the languages supported by full text search.",
                   EnableSession = false)]
        public int[] FullTextLanguages()
        {
            DataAccess da = new DataAccess();

            return da.FullTextLanguages();
        }
    }
}
